#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

ll L, R;
int c[15], num;
void init(ll n) {
  num = 0;
  while (n) {
    c[++num] = n % 10;
    n /= 10;
  }
  if (!num) c[++num] = 0;
}
ll dp[2][2][2][2][10][10][15];
ll dfs(int limit, int has8, int has4, int ok, int u, int v, int pos) {
  if (has8 && has4) return 0;
  if (!pos) {
    return ok;
  }
  ll& ans = dp[limit][has8][has4][ok][u][v][pos];
  if (ans != -1) return ans;
  ans = 0;
  int imx = limit ? c[pos] : 9;
  rep(i, 0, imx) {
    int climit = limit && i == imx;
    int chas8 = has8 || i == 8;
    int chas4 = has4 || i == 4;
    int cok = ok || (u == v && u == i);
    ll tmp = dfs(climit, chas8, chas4, cok, i, u, pos - 1);
    ans += tmp;
  }
  return ans;
}
ll solve(ll n) {
  init(n);
  if (num != 11) return 0;
  memset(dp, -1, sizeof(dp));
  ll res = 0;
  rep(i, 1, c[num]) res += dfs(i == c[num], i == 8, i == 4, 0, i, 0, num - 1);
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> L >> R;
  cout << solve(R) - solve(L - 1);
  return 0;
}